import Vue from 'vue'
import * as types from './mutation-types'

export default {
  [types.TODO_ADD] (state, todo) {
    state.todos.push(todo)
  },
  [types.TODO_DELETE] (state, {id}) {
    state.todos = state.todos.filter(todo => id != todo.id)
  },
  [types.TODO_TOGGLE] (state, todo) {
    todo.done = !todo.done
  },
  [types.TODO_EDIT_TEXT] (state, {text, todo}) {
    todo.text = text
  }
};
